Repository navigation
fix(cursor): mcp.json servers using ${workspaceFolder} now start - #24505
Merged
juliusmarminge merged 20 commits intoNov 12, 2026
Merged
juliusmarminge merged 20 commits into
juliusmarminge merged 20 commits into
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A
.cursor/mcp.jsonserver started asnode ${workspaceFolder}/server.mjsworks in the Cursor editor but crashes in Cursor threads in T3: the bundled Cursor SDK leaves Cursor's editor variables literal, so Node exits withMODULE_NOT_FOUND.Change
When the Cursor adapter opens an agent, it reads the same two files, resolves the editor variables in each stdio server whose executable or leading script path uses one, and passes that copy as an agent-level MCP server.
${workspaceFolder}is the project root: the output ofgit rev-parse --show-toplevel, matching the SDK, with the cwd as fallback.The SDK loads agent-level servers first and keeps the first per name, so the resolved client wins after both sources have loaded. This is the agent-level path https://git.cafe/pingdotgg/t3code/pulls/15875 kept for the
t3-codeserver; it merges with file servers instead of replacing them.Servers without editor variables in their executable or leading non-flag argument are left alone. Env-only, cwd-only, and trailing argument placeholders remain with the SDK, avoiding extra healthy processes.
Scope
Bug fix: a server the user configured crashes at start in Cursor threads. Fixes https://git.cafe/pingdotgg/t3code/issues/22199.
Verification
Head
4ea0d8d161042c3c4e38b2590012e6d4e822152dmerges current main without rebasing. The only merge conflict was imports; main's orchestration prompt and the workspace loader are both preserved.vp run check:changedpassed formatting, lint, both knip passes, unused-patch install validation, 39 affected package typechecks, and 23 tests.No UI changes. Historical evidence from the original implementation follows; it does not establish authenticated client integration.
Current scope, head
1ebaebb3cfThe launch-path-only sentences in Change, Verification and Takeover verification describe an earlier scope, before
e49122c6e1.On this head, a stdio server with an editor variable anywhere in its definition, or an unset
${env:NAME}, gets a resolved copy. The agent starts with T3's MCP server only; each turn sends it plus the resolved servers, read again (e2910ec7a6), because Cursor SDK 1.2.0 replaces the agent's set with the turn's.To see it on Linux web: sign in to Cursor in Settings > Providers, open a project whose
.cursor/mcp.jsonstartsnode ${workspaceFolder}/server.mjs, and ask a Cursor thread to call its tool.Signed-in run, main first, with
sample-offdisabled andsample-laterdisabled between turns. Main fails both turns and starts no server; oncf589210d1each enabled server starts once per turn andsample-offnever starts. The runs were oncf589210d1;1ebaebb3cfthen stops sending an empty server set with a turn and makes the server bundle use jsonc-parser's ESM entry, so the built server starts.Main bfec275, turn 1: MCP server does not exist: sample-tools, no echo reply

cf58921, turn 1: sample-tools says: marker-one; tools sample_later_echo and sample_tools_echo

cf58921, turn 2, sample-later switched off: marker-two; only sample_tools_echo

Not checked here: Windows (run in the thread on
1b60d28), desktop and mobile (no client code changed), remote, relay and tunnel, and${userHome}in a user-level server when the runtime cwd is null.Send logs, checks, start logs and the longer description
Head
1ebaebb3cf: maria-rcks's1b60d28cb6, one merge of mainbfec2754b8, thene2910ec7a6(fix),cf589210d1(test only) and1ebaebb3cf(no empty server set sent with a turn; the server bundle resolves jsonc-parser's ESM entry). The signed-in run below was oncf589210d1. I ran a signed-in Cursor thread on test servers named "Test machine": Cursor signed in through T3's browser sign-in, Composer 2.5, Cursor SDK 1.2.0, web client in T3's Browser panel, prompts typed in the Browser panel. Main ran first, thencf589210d1. The project's.cursor/mcp.jsonhas three stdio servers started asnode ${workspaceFolder}/server.mjs <name>.sample-offis listed in Cursor'smcp-disabled.json, and I addedsample-laterto that list between turn 1 and turn 2. Each server writes a line to a log when it starts.The adapter's own send log,
run.startoptions without the message text. Mainbfec2754b8:cf589210d1:Main now sends T3's MCP server with every turn, and in Cursor SDK 1.2.0 a server set sent with a turn replaces the set the agent was created with. A plain merge would send only
t3-code, so the resolved servers would drop out. The merge sends them with each turn.e2910ec7a6resolves them again on each turn and creates the agent with T3's server only: with the merge alone, the same run startedsample-lateragain on turn 2, and passing the resolved servers at creation as well started each server twice.cf589210d1makes the workspace-variable test expect the root thatgit rev-parse --show-toplevelprints, which uses forward slashes on Windows.On
cf589210d1,vp run check:changedpasses and all 131 provider-cursor tests pass on Node 26.12.1; the extended workspace-variable test fails with main'sadapter.tsand with the merge'sadapter.ts, and passes. On1ebaebb3cf, the same 131 tests pass, four apps/server suites that replay Cursor pass (20 tests; the 12 replay-fixture and recovery tests among them fail oncf589210d1),vp run check:changedpasses, and the built server starts.Main
bfec2754b8, after both turns:cf589210d1, after both turns:Main bfec275, turn 2: the same failure, MCP server does not exist: sample-tools

Longer description, as written before this head:
Fixes https://git.cafe/pingdotgg/t3code/issues/22199. A
.cursor/mcp.jsonserver with"args": ["${workspaceFolder}/server.mjs"]works in the Cursor editor, but Cursor threads in T3 never get it.The bundled Cursor SDK reads
.cursor/mcp.jsonand~/.cursor/mcp.jsonitself, and it expands only environment placeholders (${env:NAME},${NAME},${NAME:-default}). Cursor's editor variables (${workspaceFolder},${workspaceFolderBasename},${userHome},${pathSeparator},${/}) stay literal. Node then looks for a file named${workspaceFolder}/server.mjsand exits withMODULE_NOT_FOUND. SDK 1.0.40 and 1.1.0-beta.0 do the same, so an SDK bump does not fix it.Bug fix for https://git.cafe/pingdotgg/t3code/issues/22199. A maintainer reproduced the setup in this comment and could not go further without an authenticated Cursor account. The change stays inside the Cursor adapter.
The SDK still handles everything else: A project server shadows a user server with the same name, as in the SDK. A server listed in Cursor's
mcp-disabled.jsonfor the project stays off. A server named like a plugin server (plugin-<plugin>-<name>) is left to the SDK, which prefers enabled plugin servers over file servers. Environment placeholders resolve from the Cursor provider's environment before the file is validated, as in the SDK, so"type": "${env:MCP_TYPE}"is accepted. The SDK still loads its own unresolved copy. Only the resolved copy reaches the agent, because the first server per name wins. In the issue's setup the unresolved copy exits at once with a load warning, as it does today.jsonc-parser(the versionapps/webuses) parses the files, since Cursor allows comments and trailing commas inmcp.json.Prior PRs:
mcp-disabled.json.Takeover fixup and verification by
gpt-6.1-solthrough the Codex harness in T3 Code.Takeover verification
The final scope remains five files, 323 additions and 2 deletions against current main. Custom
startupTimeoutSecis preserved. Main was merged, never rebased. The old filesystem-probe bot finding was replied to and resolved because that code no longer exists.The actual loader and SDK 1.0.38 workspace initialization were exercised together using isolated state and real stdio MCP handshakes:
All probe children exited and temporary state was removed. This verifies SDK startup, not an authenticated Cursor model turn through the T3 client. That client verification remains blocked by missing Cursor credentials. One independent reviewer cleared the final script-path scope; the second hit a provider rate limit and returned no verdict. Macroscope requires human approval. Final CI status is tracked in the takeover comment.
Fixes #22199
Generated with Claude Opus 5.5 and GPT-6.1 Sol in T3 Code Nightly